Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Rename the method whereNone to whereNotAny in the query builder #52383

Conversation

einar-hansen
Copy link
Contributor

The PR#52361 suggests the introduction of the negated version for whereAll called whereNotAll. This got me thinking about the naming of the whereNone query that was published in the last release, which is the negated version of whereAny. With the introduction of whereNotAll, I realized we might want to reconsider the name of whereNone for clarity and consistency, as none is the opposite to both "any" and "all".

I propose renaming whereNone to whereNotAny. Here's why:

  1. It's clearer what the method does in relation to whereAny.
  2. It follows the naming pattern of whereNotAll, and most of the other queries in the framework, for example; whereIn/whereNotIn, whereLike/whereNotLike, whereBetween/whereNotBetween and so on...
  3. It would be easier for developers to understand the relationship between all these methods.

If we make this change, our method names would be:

  • whereAll: Return rows where all conditions are true
  • whereNotAll: Return rows excluding where all conditions are true
  • whereAny: Return rows where at least one condition is true
  • whereNotAny: Return rows excluding where at least one condition is true (currently whereNone)

The name whereNotAny might be a bit clunkier, but I think it provides a clearer developer experience, especially when considered alongside whereNotAll.

This PR adds the @deprecated tag to the docblocks of whereNone (since users might already started using it), and makes whereNone forward all arguments to whereNotAny, so that we in the future can remove the whereNone methods safely. Also the tests have been updated with tests for the new naming.

The docblocks are updated to accept \Illuminate\Contracts\Database\Query\Expression[], since the user can pass in column names from the DB::raw() method, also the $operator is changed from string to mixed, to match the signature in the where method.

@einar-hansen einar-hansen changed the title [11.x] Rename the method whereNone to whereNotAll in the query builder [11.x] Rename the method whereNone to whereNotAny in the query builder Aug 5, 2024
@taylorotwell
Copy link
Member

Going to leave it as is for now since I didn't merge the other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants